	//	JavaScript Document
	//	numberUtils.js
	//	Utilities for numberic data type such as reformat, change type to string ...
	//	Author	Manz
	//	16/01/2003

	/*
		Function checkValidNumber.
		Use to check the argument is numberic data type or not.
		Return true if the argument is numberic data type such as 1, 2.30, 25.022011101
	*/
	function checkValidNumber(obj) {
		if(isNaN(toNumber(obj.value))) {
			showOWarningDialog("Invalid value.", "Invalid number format.", "OK");
			obj.select() ;
			return false ;
		} else {
			obj.value = toCurrency(obj.value) ;
			return true ;
		}
	}

	/*
		Function shiftPoint.
		Use to clear the number argument, decimal fraction to less than 2 decimal from decimal point.
		The src is number argument.
	*/
	function shiftPoint(src) {
		/*alert("src = " + src);
		alert("new Number(src) = " + new Number(src));
		alert("Number.MAX_VALUE = " + Number.MAX_VALUE);
		alert(new Number(src) == Number.MAX_VALUE) ;
		 if(new Number(src) == Number.MAX_VALUE)  // Found Max Value Number
                  return src ;*/
		var intNum = parseInt(src) ;
		var floatNum = 0 ;
		src += "" ;
		if(src.indexOf("-") == 0 && intNum == 0) {
			intNum = "-" + intNum ;
		}
		if(src.indexOf(".") >= 0) {
			src += "0000" ;
//alert(src.substring(src.indexOf(".") + 1, src.indexOf(".") + 5)) ;
//alert(parseFloat(src.substring(src.indexOf(".") + 1, src.indexOf(".") + 5) / 100)) ;
//alert(Math.round(parseFloat(src.substring(src.indexOf(".") + 1, src.indexOf(".") + 5) / 100))) ;
			floatNum = Math.round(parseFloat(src.substring(src.indexOf(".") + 1, src.indexOf(".") + 5) / 100)) ;
			if(floatNum < 10)
				floatNum = "0" + floatNum ;
			else
				if(floatNum == 100)
					return (new Number(intNum)+1) + ".00" ;
				else
					floatNum += "00" ;
			floatNum = floatNum.substring(0, 2) ;
//			if(auto) {
//				var temp = new Number(intNum) + autoSnap(floatNum) + "" ;
//				if(temp.indexOf(".") >= 0) {
//					temp += "00" ;
//					return temp.substring(0, temp.indexOf(".") + 3) ;
//				} else {
//					return temp ;
//				}
//			} else {
				return intNum+"."+floatNum ;
//			}
		} else {
			return src + ".00" ;
		}
	}


	/*
		Function toNumber.
		Use to change data type from string to numberic.
		The string argument must be cleared all innumberic characters before change to numberic data type.
	*/
	function toNumber(src) {
		src = src + "" ;
		while(src.indexOf(",") >= 0) {
			 src = src.replace(",", "") ;
		}
		return new Number(shiftPoint(src, false)) ;
	}

	/*
		Function toCurrency.
		Use to change numberic argument to string, format 99,999,999,999.##
	*/
	function toCurrency(src) {
		src = shiftPoint(toNumber(src), false) + "" ;
		var isNegative = src.indexOf("-") == 0 ;
		src = isNegative ? src.substring(1) : src ;
		var currencySrc = "" ;
		var tempIntNum = ( src.indexOf(".") >= 0 ? src.substring(0, src.indexOf(".")) : src ) ;
		var floatNum = ( src.indexOf(".") >= 0 ? (src + "00").substring(src.indexOf("."), src.indexOf(".") + 3) : ".00" ) ;
//alert(src.indexOf(".") + " org " + src + " : " + tempIntNum + " : " + floatNum) ;
		var intNum = new String() ;
		var maxComma = Math.ceil(tempIntNum.length / 3) ;

		if(tempIntNum.length < 3) {
			return isNegative ? "-" + tempIntNum + floatNum : tempIntNum + floatNum ;
		} else {
			for(i = tempIntNum.length ; i >= 0 ; i--)	// reverse
				intNum += tempIntNum.charAt(i) ;

			for(i = 0 ; i < maxComma ; i++) {
				currencySrc += intNum.substr((i*3), 3) + "," ;
			}

			intNum = "" ;
			for(i = currencySrc.length - 2 ; i >= 0 ; i--)	//	 reverse
				intNum += currencySrc.charAt(i) ;
			return isNegative ? "-" + intNum + floatNum : intNum + floatNum ;
		}
	}